#!/bin/bash
set -e

XCODEPATH=$(xcode-select -p)

if [[ ! -e "$XCODEPATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk" ]]; then
	echo "*** ERROR: the macOS 10.14 SDK is required. Please refer to" \
		"https://github.com/FooBarWidget/traveling-ruby/blob/main/osx/README.md" \
		"for installation instructions." >&2
	exit 1
fi

if [[ -e /usr/local/include ]]; then
	echo "*** ERROR: /usr/local/include exists, which may pollute the" \
		"build environment. Please temporarily rename it away:" >&2
	echo >&2
	echo "    rake stash_conflicting_paths" >&2
	exit 1
fi

if [[ -e /usr/local/lib ]]; then
	echo "*** ERROR: /usr/local/lib exists, which may pollute the" \
		"build environment. Please temporarily rename it away:" >&2
	echo >&2
	echo "    rake stash_conflicting_paths" >&2
	exit 1
fi
